/*
 * Copyright 2016 Wealth Inc. All rights reserved.
 */
 package com.wealth.order.entity;


import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wealth.commodity.entity.Goods;

@Entity
@Table(name = "t_order_item")
public class OrderItem implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Long id;
	private Double price;
	private Integer amount;
	private Goods goods;
	private Order order;
	private Integer commentstatus;
	
	
	/* ---------------- method ----------------*/
	
	public OrderItem(){
	}

	public OrderItem(Long id){
		this.id = id;
	}

	/* ---------------- getter/setter ----------------*/
	
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "price")
	public Double getPrice() {
		return price;
	}
	
	public void setPrice(Double price) {
		this.price = price;
	}
	
	@Column(name = "amount")
	public Integer getAmount() {
		return amount;
	}
	
	public void setAmount(Integer amount) {
		this.amount = amount;
	}
	
	@ManyToOne
	@JoinColumn(name="goods_id")
	public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	@ManyToOne
	@JoinColumn(name="order_id")
	@JsonIgnore
	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}
	
	@Transient
	public Date getCreateTime(){
		return order.getCreateTime();
	}
	@Transient
	public String getAddress(){
		return order.getAddress();
	}
	@Transient
	public String getReceiver(){
		return order.getReceiver();
	}
	@Transient
	public String getTelephone(){
		return order.getTelephone();
	}
	@Transient
	public String getOrderno(){
		return order.getOrderno();
	}
	@Transient
	public Integer getPaystatus(){
		return order.getPaystatus();
	}
	@Transient
	public String getUsername(){
		return order.getMember().getUsername();
	}
	@Transient
	public String getNickname(){
		return order.getMember().getNickname();
	}

	public Integer getCommentstatus() {
		return commentstatus;
	}

	public void setCommentstatus(Integer commentstatus) {
		this.commentstatus = commentstatus;
	}
		
}



